// 初始化中小市场分类服务项目数据
// 运行方式：在微信开发者工具控制台中执行此脚本

const smeServices = [
  {
    title: "企宽延伸",
    description: "为企业提供专业的宽带网络延伸服务，扩展网络覆盖范围，提升网络连接质量",
    category: "sme_market",
    price: 2800,
    unit: "月",
    rating: "4.8",
    badge: "热门",
    tags: ["企业宽带", "网络延伸", "专线服务"],
    image: "https://images.unsplash.com/photo-1558494949-ef010cbdcc31?w=400&h=300&fit=crop",
    features: [
      "专业网络规划设计",
      "高速稳定连接",
      "7x24小时技术支持",
      "灵活扩展方案"
    ],
    serviceProcess: [
      "需求分析与现场勘测",
      "网络方案设计",
      "设备安装调试",
      "网络优化测试",
      "交付使用培训"
    ]
  },
  {
    title: "商宽延伸",
    description: "商业宽带网络延伸解决方案，为商业场所提供高质量网络连接服务",
    category: "sme_market",
    price: 3200,
    unit: "月",
    rating: "4.7",
    badge: "推荐",
    tags: ["商业宽带", "网络覆盖", "高速连接"],
    image: "https://images.unsplash.com/photo-1560472354-b33ff0c44a43?w=400&h=300&fit=crop",
    features: [
      "商业级网络质量",
      "多点位覆盖",
      "负载均衡技术",
      "实时监控管理"
    ],
    serviceProcess: [
      "商业需求评估",
      "网络架构设计",
      "专业设备部署",
      "网络性能调优",
      "运维服务交付"
    ]
  },
  {
    title: "维保服务",
    description: "专业的IT设备维护保养服务，确保企业信息系统稳定运行",
    category: "sme_market",
    price: 1800,
    unit: "月",
    rating: "4.9",
    badge: "优质",
    tags: ["设备维护", "系统保养", "故障排除"],
    image: "https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?w=400&h=300&fit=crop",
    features: [
      "定期巡检维护",
      "故障快速响应",
      "预防性维护",
      "备件库存管理"
    ],
    serviceProcess: [
      "设备状态评估",
      "维护计划制定",
      "定期保养执行",
      "故障处理响应",
      "维护报告提交"
    ]
  },
  {
    title: "e企组网",
    description: "企业级组网解决方案，构建安全高效的企业内部网络环境",
    category: "sme_market",
    price: 5800,
    unit: "套",
    rating: "4.8",
    badge: "专业",
    tags: ["企业组网", "网络安全", "系统集成"],
    image: "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400&h=300&fit=crop",
    features: [
      "企业级网络架构",
      "安全防护体系",
      "统一网络管理",
      "可扩展设计"
    ],
    serviceProcess: [
      "网络需求调研",
      "组网方案设计",
      "网络设备部署",
      "安全策略配置",
      "网络测试验收"
    ]
  },
  {
    title: "e企收银",
    description: "智能收银系统解决方案，提升企业收银效率和客户体验",
    category: "sme_market",
    price: 3600,
    unit: "套",
    rating: "4.6",
    badge: "智能",
    tags: ["智能收银", "支付系统", "数据分析"],
    image: "https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=400&h=300&fit=crop",
    features: [
      "多种支付方式",
      "实时数据统计",
      "库存管理集成",
      "会员系统支持"
    ],
    serviceProcess: [
      "业务需求分析",
      "系统方案设计",
      "软硬件部署",
      "数据迁移配置",
      "操作培训交付"
    ]
  },
  {
    title: "云视讯",
    description: "企业级视频会议解决方案，支持高清视频通话和远程协作",
    category: "sme_market",
    price: 2400,
    unit: "月",
    rating: "4.7",
    badge: "高清",
    tags: ["视频会议", "远程协作", "云服务"],
    image: "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=400&h=300&fit=crop",
    features: [
      "高清视频通话",
      "多方会议支持",
      "屏幕共享功能",
      "会议录制回放"
    ],
    serviceProcess: [
      "会议需求评估",
      "系统部署配置",
      "用户账号开通",
      "使用培训指导",
      "技术支持服务"
    ]
  }
]

// 初始化函数
async function initSmeServices() {
  console.log('🚀 开始初始化中小市场分类服务项目...')
  
  try {
    // 调用云函数批量添加服务项目
    const result = await wx.cloud.callFunction({
      name: 'businessManager',
      data: {
        action: 'batchCreateServices',
        data: {
          services: smeServices
        }
      }
    })
    
    if (result.result && result.result.success) {
      console.log('✅ 中小市场服务项目初始化成功！')
      console.log(`📊 成功添加 ${smeServices.length} 项服务`)
      
      // 显示成功提示
      wx.showModal({
        title: '初始化完成',
        content: `中小市场分类下的 ${smeServices.length} 项服务已成功添加到数据库`,
        showCancel: false,
        confirmText: '确定'
      })
    } else {
      throw new Error(result.result?.error || '初始化失败')
    }
    
  } catch (error) {
    console.error('❌ 初始化失败:', error)
    wx.showModal({
      title: '初始化失败',
      content: `错误信息：${error.message}`,
      showCancel: false,
      confirmText: '确定'
    })
  }
}

// 导出初始化函数和数据
if (typeof module !== 'undefined' && module.exports) {
  module.exports = {
    smeServices,
    initSmeServices
  }
} else {
  // 在控制台中可以直接调用
  console.log('💡 中小市场服务数据已准备就绪')
  console.log('📋 服务项目列表:', smeServices.map(s => s.title))
  console.log('🔧 执行 initSmeServices() 开始初始化')
}
